import {
	LOGIN_STATUS,
	USER_INFO,
	CACHE_LATITUDE,
	CACHE_LONGITUDE,
	OPEN_ID,
} from '@/config/cache.js';

export default {
	namespaced: true,
	state: {
		token: uni.getStorageSync(LOGIN_STATUS) || false,
		userInfo: uni.getStorageSync(USER_INFO) || {},
	},
	mutations: {
		updateToken(state, payload) {
			state.token = payload
			uni.setStorageSync(LOGIN_STATUS, payload)
		},
		updateUserInfo(state, payload) {
			state.userInfo = payload
			uni.setStorageSync(USER_INFO, payload)
		},
		/** 退出登录 */
		logOut(state, payload) {
			state.token = false
			state.userInfo = {}
			uni.removeStorageSync(LOGIN_STATUS)
			uni.removeStorageSync(USER_INFO)
			uni.removeStorageSync(CACHE_LATITUDE)
			uni.removeStorageSync(CACHE_LONGITUDE)
		},
	},
	actions: {

	}
}